package com.qzsf.backend.controller;

import com.qzsf.backend.common.Result;
import com.qzsf.backend.entity.UserAuth;
import com.qzsf.backend.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/*
 * @Author: Dennis Chen
 * @CreateTime: 2024/11/8 10:40 周五
 * @Email 1429278462@qq.com
 * @Remark 权限控制器
 * @Version 1.0
 */
@RestController
@RequestMapping("role")
public class RoleController {
    @Autowired
    private RoleService roleService;
    @GetMapping
    public Result getUserAuth(@RequestParam(required = false) String username, @RequestParam int pageNo,@RequestParam int pageSize){
        return roleService.getUserAuth(username, pageNo, pageSize);
    }

    @GetMapping("/{id}")
    public Result getUserAuthById(@PathVariable int id){
        return roleService.getUserAuthById(id);
    }
    @DeleteMapping("/{id}")
    public Result deleteUserAuth(@PathVariable int id){
        return roleService.deleteUserAuth(id);
    }

    @PutMapping
    public Result updateUserAuth(@RequestBody UserAuth userAuth){
        return roleService.updateUserAuth(userAuth);
    }

    @PostMapping
    public Result createUserAuth(@RequestBody UserAuth userAuth){
        return  roleService.createUserAuth(userAuth);
    }
}
